-module(p4).
-export([result/0]).

result() -> 
    Palindroms = get_palindroms(lists:seq(100, 999)),
    lists:max(Palindroms).

get_palindroms(Seq) ->
    [A * B || A <- Seq, B <- Seq, is_palindrom(A * B)].

is_palindrom(Num) -> Num =:= reversed_number(Num).

reversed_number(Num) ->
    List = erlang:integer_to_list(Num),
    List_reversed = lists:reverse(List),
    erlang:list_to_integer(List_reversed).
